#if DEBUG

using System.Xml.Linq;
using FluentlyXml.Core;
using FluentlyXml.Core.DSL;
using FluentlyXml.UnitTests.Core.TestObjects;
using NUnit.Framework;

namespace FluentlyXml.UnitTests.Core
{
	public class WidgetSerializationTests
	{
		[TestFixture]
		public class When_serializing_a_widget
		{
			private XElement _xml;

			[SetUp]
			public void When()
			{
				var widget = Widget.GetTestWidget();

				var factory = new FluentSerializerFactory(x =>
				                                          	{
				                                          		x.ApplyConfigFrom<WidgetSerializationSpec>();
				                                          	});

				var serializer = factory.CreateSerializer();

				_xml = serializer.Serialize(widget);
			}

			[Test]
			public void Then_it_does_not_serialize_Dummy1()
			{
				Assert.That(_xml.ToString(), Is.Not.StringContaining("<Dummy1>"));
			}

			[Test]
			public void Then_it_does_not_serialize_Dummy2()
			{
				Assert.That(_xml.ToString(), Is.Not.StringContaining("<Dummy2>"));
			}

			[Test]
			public void Then_it_serializes_Name()
			{
				Assert.That(_xml.ToString(), Is.StringContaining("<Name>"));
			}

			[Test]
			public void Then_it_serialized_the_ID()
			{
				Assert.That(_xml.ToString(), Is.StringContaining("<Id>"));
			}
		}
	}

	public class WidgetSerializationSpec : FluentSerializationSpec
	{
		public WidgetSerializationSpec()
		{
			var spec = WhenSerializing<Widget>()
				.IgnoreAllProperties();
			
			spec.Serialize(w => w.Name).AsElement();

			spec.Serialize(w => w.Id).AsElement();
		}
	}
}

#endif